\CUSDependency{package={needspace}}
\CUSProvideExplModule{space}{\cus@d@te}{\cus@versi@n}{space setting}

\NewDocumentCommand \page { +O{} }
  {
    
  }

\ekeysdeclarecmd \NeedspaceTF { s m }
  {
    \par \penalty-100\begingroup
    \setlength{\dimen@}{\dimexpr#2}
    \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
    \ifdim \dimen@>\dimen@ii
      \bool_lazy_and:nnT {!#1} { \dim_compare_p:nNn { \dimen@ii } > { \z@ } } { \vfil }
      \penalty-\@M
    \fi\endgroup
    \bool_lazy_or:nnTF
      { \dim_compare_p:nNn { \pagegoal } = { \c_max_dim} }
      { \int_compare_p:nNn { \lastpenalty } < { -9999 } } % -\@M = -10000
  }

\protected\def\needhspace#1{
  \leavevmode
  \begingroup
  \setlength\skip@{\glueexpr#1}%
  \hskip\z@\@plus\skip@
  \penalty -100\hskip\z@\@plus -\skip@
  \hskip\skip@
  \penalty 9999
  \hskip -\skip@
  \hskip\z@skip
  \endgroup}

\protected\def\breakablevspace#1{%
  \begingroup
  \@tempskipa\glueexpr#1\relax \@tempskipb\@tempskipa
  \divide\@tempskipa\sixt@@n
  \ifdim\@tempskipa>\baselineskip 
    \@tempskipa.5\baselineskip plus.1\baselineskip minus.1\baselineskip\fi 
  \loop
    \vskip\@tempskipa \hrule height\z@ depth\z@
    \advance\@tempskipb-\@tempskipa
    \ifdim\@tempskipb>\z@ \repeat
  \endgroup}
\protected\def\breakablehspace#1{%
  \ifvmode\else
    \begingroup\leavevmode
    \@tempskipa\glueexpr#1\relax \@tempskipb\@tempskipa
    \divide\@tempskipa\sixt@@n 
    \ifdim\@tempskipa>.5em \@tempskipa .5em plus.1em minus.1em\fi 
    \loop
      \hskip\@tempskipa\null
      \advance\@tempskipb-\@tempskipa
      \ifdim\@tempskipb>\z@ \repeat
    \endgroup
  \fi}